# -*- coding: utf-8 -*-
from com.zjs.crawer.urlcontent.baseurlcontent import BaseUrlContent
from com.zjs.zjsqueue import zurlpathqueue
import logging

class taobaoHooks(BaseUrlContent):
    
    __homeurl = None
    
    name = "taobao"
    
    def __init__(self,homeurl):
        self.__homeurl = homeurl
        print("启动 hook:"+self.name)
    
    
    def run(self):
        loc=["安徽","福建","甘肃","广东","广西","贵州","海南","河北",
         "河南","湖北","湖南","江苏","江西","吉林","辽宁","宁夏",
        "青海","山东","山西","陕西","云南","四川","西藏","新疆",
        "浙江","澳门","香港","台湾","内蒙古","黑龙江","北京","上海","海外","重庆","天津"
        ]
        loc_onepage=["宁夏","青海","澳门","西藏"]
        for pro in loc :  
            if pro in loc_onepage:
                url="https://shopsearch.taobao.com/search?app=shopsearch&q=%E6%95%B0%E7%A0%81&imgfile=&js=1&stats_click=search_radio_all%3A1&initiative_id=staobaoz_20170609&ie=utf8&loc={0}".format(pro)
            else :    
                url="https://shopsearch.taobao.com/search?app=shopsearch&q=%E6%95%B0%E7%A0%81&imgfile=&js=1&stats_click=search_radio_all%3A1&initiative_id=staobaoz_20170609&ie=utf8&loc={0}&s=0".format(pro)
                logging.debug("[taobao]["+self.name+"https://shopsearch.taobao.com/search?app=shopsearch&q=%E6%95%B0%E7%A0%81&imgfile=&js=1&stats_click=search_radio_all%3A1&initiative_id=staobaoz_20170609&ie=utf8&loc={0}&s=0".format(pro))
            zurlpathqueue.put(self.name,url) 
                                                 
       